import Base from 'models/base';

import SystemUtil from 'utils/systemUtil';

export default class Advertisement extends Base {
  constructor(data) {
    super();

    let advertiseTopList = [],
      advertiseBottomList = [];
    for (let i = 0; i < data.length; i++) {
      const obj = data[i];
      let type = obj.advertisementType;
      if (type === 3) {
        continue;
      }
      let ad = {
        type,
        id: obj.advertisementId + '',
        href: obj.advertisementHref,
        name: obj.advertisementName,
        sort: obj.advertisementSort,
        imgUrl: obj.advertisementUrl
      };
      if (type === 1) {
        advertiseTopList.push(ad);
      } else {
        advertiseBottomList.push(ad);
      }
    }

    advertiseBottomList = SystemUtil.getRadomArrayData(advertiseBottomList, 2);

    this.advertiseTopList = advertiseTopList;
    this.advertiseBottomList = advertiseBottomList;
  }
}
